

<%@ page import="dealfinder.Deal" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'deal.label', default: 'Deal')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${dealInstance}">
            <div class="errors">
                <g:renderErrors bean="${dealInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post"  enctype="multipart/form-data">
                <g:hiddenField name="id" value="${dealInstance?.id}" />
                <g:hiddenField name="version" value="${dealInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="companyName"><g:message code="deal.companyName.label" default="Company Name" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'companyName', 'errors')}">
                                    <g:textField name="companyName" value="${dealInstance?.companyName}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="name"><g:message code="deal.name.label" default="Name" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" value="${dealInstance?.name}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="informationText"><g:message code="deal.informationText.label" default="Information Text" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'informationText', 'errors')}">
                                    <g:textField name="informationText" value="${dealInstance?.informationText}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="originalPrice"><g:message code="deal.originalPrice.label" default="Original Price" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'originalPrice', 'errors')}">
                                    <g:textField name="originalPrice" value="${fieldValue(bean: dealInstance, field: 'originalPrice')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dealPrice"><g:message code="deal.dealPrice.label" default="Deal Price" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'dealPrice', 'errors')}">
                                    <g:textField name="dealPrice" value="${fieldValue(bean: dealInstance, field: 'dealPrice')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="mainImage"><g:message code="deal.mainImage.label" default="Main Image" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'mainImage', 'errors')}">
                                    <input type="file" id="mainImage" name="mainImage" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="active"><g:message code="deal.active.label" default="Active" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'active', 'errors')}">
                                    <g:checkBox name="active" value="${dealInstance?.active}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="address"><g:message code="deal.address.label" default="Address" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'address', 'errors')}">
                                    <g:textField name="address" value="${dealInstance?.address}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="city"><g:message code="deal.city.label" default="City" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'city', 'errors')}">
                                    <g:select name="city.id" from="${dealfinder.City.list()}" optionKey="id" value="${dealInstance?.city?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="endTime"><g:message code="deal.endTime.label" default="End Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'endTime', 'errors')}">
                                    <g:datePicker name="endTime" precision="day" value="${dealInstance?.endTime}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="images"><g:message code="deal.images.label" default="Images" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'images', 'errors')}">
                                    
<ul>
<g:each in="${dealInstance?.images?}" var="i">
    <li><g:link controller="image" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="image" action="create" params="['deal.id': dealInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'image.label', default: 'Image')])}</g:link>

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="maxUsers"><g:message code="deal.maxUsers.label" default="Max Users" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'maxUsers', 'errors')}">
                                    <g:textField name="maxUsers" value="${fieldValue(bean: dealInstance, field: 'maxUsers')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="minUsers"><g:message code="deal.minUsers.label" default="Min Users" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'minUsers', 'errors')}">
                                    <g:textField name="minUsers" value="${fieldValue(bean: dealInstance, field: 'minUsers')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="postalCode"><g:message code="deal.postalCode.label" default="Postal Code" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'postalCode', 'errors')}">
                                    <g:textField name="postalCode" value="${fieldValue(bean: dealInstance, field: 'postalCode')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="shortDescription"><g:message code="deal.shortDescription.label" default="Short Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'shortDescription', 'errors')}">
                                    <g:textField name="shortDescription" value="${dealInstance?.shortDescription}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="startTime"><g:message code="deal.startTime.label" default="Start Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'startTime', 'errors')}">
                                    <g:datePicker name="startTime" precision="day" value="${dealInstance?.startTime}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="streetNr"><g:message code="deal.streetNr.label" default="Street Nr" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'streetNr', 'errors')}">
                                    <g:textField name="streetNr" value="${fieldValue(bean: dealInstance, field: 'streetNr')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="tag"><g:message code="deal.tag.label" default="Tag" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'tag', 'errors')}">
                                    <g:select name="tag.id" from="${dealfinder.Tag.list()}" optionKey="id" value="${dealInstance?.tag?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="users"><g:message code="deal.users.label" default="Users" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'users', 'errors')}">
                                    
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
